import com.aliyun.odps.udf.UDF;
import com.aliyun.odps.utils.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BeautyExpertTitleGetVolume extends UDF {

    public String evaluate(String title){
        if (StringUtils.isNotBlank(title)){
            //将括号处理掉
            if (title.contains("(") || title.contains("（")){
                title = title.replace("("," ");
                title = title.replace("（"," ");
            }
            if (title.contains(")") || title.contains("）")){
                title = title.replace(")","");
                title = title.replace("）","");
            }
            String[] titleArr = title.split(" ");
            //匹配到数字
            String regex = "\\d+";
            Pattern pattern = Pattern.compile(regex);
            for (String arrI :titleArr){
                Matcher matcher = pattern.matcher(arrI);
                if(matcher.find()){
                    return arrI;
                }
            }

        }
        return null;
    }
}
